package com.musifind.wsclient.helpers;

import java.util.Date;
import java.util.LinkedHashMap;

import android.util.Base64;

import com.musifind.wsclient.objects.User;

public class UserHelper {
	// HELPER
	public static User getUserFromLinkedHashMap(LinkedHashMap map) {
		User user = new User();
		user.setId(new Integer("" + map.get("id")));
		user.setAd((String) map.get("ad"));
		user.setSoyad((String) map.get("soyad"));
		user.setMail((String) map.get("mail"));
		user.setSifre((String) map.get("sifre"));
		user.setDogumTarih(new Date((Long) map.get("dogumTarih")));
		user.setCinsiyet((String) map.get("cinsiyet"));
		user.setDeleted((Boolean) map.get("deleted"));
		user.setGcmRegId((String) map.get("gcmRegId"));
		user.setFaceId((String) map.get("faceId"));
		user.setFaceUser((Boolean) map.get("faceUser"));

		String image = (String) map.get("image");
		byte[] byteImage = null;
		if (image != null && !image.isEmpty())
			byteImage = Base64.decode(image, Base64.DEFAULT);
		user.setImage(byteImage);
		user.setTarih(new Date((Long) map.get("tarih")));
		return user;
	}
}
